package wc

import (
	"github.com/astaxie/beego/context"
	"github.com/silenceper/wechat/miniprogram"
)

func Response(ctx *context.Context, status int, msg string, object interface{}) {
	ctx.Output.JSON(map[string]interface{}{"status": status, "msg": msg, "object": object}, false, false)
	return
}

type ResCode2Session struct {
	OpenID     string `json:"openid" bson:"openid"`       // 用户唯一标识
	SessionKey string `json:"session_key" bson:"session"` // 会话密钥
	UnionID    string `json:"unionid" bson:"union_id"`    // 用户在开放平台的唯一标识符，在满足UnionID下发条件的情况下会返回
}

func (r *ResCode2Session) Reset() {
	r.SessionKey = ""
	r.UnionID = ""
	r.OpenID = ""
	return
}

func (r *ResCode2Session) CopyFromCode2Session(session *miniprogram.ResCode2Session) {
	r.Reset()
	r.OpenID = session.OpenID
	r.UnionID = session.UnionID
	r.SessionKey = session.SessionKey
	return
}
